class RecentCounter:

    def __init__(self):
        self.queue = []

    def ping(self, t: int) -> int:
        self.queue.append(t)
        while self.queue[0] < t - 3000:
            self.queue.pop(0) # 队列是先入先出
        return len(self.queue)


if __name__ == '__main__':
    # 输入
    operations = ["RecentCounter", "ping", "ping", "ping", "ping"]
    values = [[], [1], [100], [3001], [3002]]

    output = []

    for i in range(len(operations)):
        if operations[i] == "RecentCounter":
            recentCounter = RecentCounter()
            output.append(None)  # 对应输出 null
        elif operations[i] == "ping":
            res = recentCounter.ping(values[i][0])
            output.append(res)

    print(output)
